BIN=code
CC=gcc
SRC=$(wildcard *.c)
OBJ=$(SRC:.c=.o)
LFLAGS=-o
RM=rm -f
FLAGS=-c

$(BIN):$(OBJ)
	@$(CC) $(LFLAGS) $@ $^
	@echo "link ... $^ to $@"
%.o:%.c
	@$(CC) $(FLAGS) $<
	@echo "compling ... $< to $@"
.PHONY:clean
clean:
	@$(RM) $(OBJ) $(BIN)
	@echo "remove complete!"
.PHONY:test
test:
	@echo $(SRC)
	@echo $(OBJ)





#BIN=code
#CC=gcc
#SRC=code.c
#OBJ=code.o
#LFLAGS=-o
#RM=rm -f
#FLAGS=-c
#
#$(BIN):$(OBJ)
#	$(CC) $(LFLAGS) $@ $^
#%.o:%.c
#	$(CC) $(FLAGS) $<
#
#.PHONY:clean
#clean:
#	$(RM) $(OBJ) $(BIN)











#$(BIN):$(SRC)
#	@$(CC) $(FLAGS) $@ $^
#	@echo "Link …$(BIN)"
#.PHONY:clean
#clean:
#	@$(RM) $(BIN)
#	@echo "remove …$(BIN)"
#.PHONY:test
#test:
#	@echo $(BIN)
#	@echo $(CC)
#	@echo $(SRC)
#	@echo $(FLAGS)














#.PHONY:code 
#code:code.c
#	gcc -o code code.c
#.PHONY:clean
#clean:
#	rm -f code

#code:code.o
#	gcc code.o -o code
#code.o:code.s
#	gcc -c code.s -o code.o
#code.s:code.i
#	gcc -S code.i -o code.s
#code.i:code.c
#	gcc -E code.c -o code.i

#.PHONY:clean
#clean:
#	rm -f *.i *.s *.o code
